package edu.sctu.zhengsenwen.month201506.day20150615.files;


import java.io.*;
import java.text.MessageFormat;

/**
 * Created by user15 on 2015/6/14.
 */
public class Seriousnize {


    private static void Seriousnizep() {

    }

    public static void main(String[] args) throws Exception {

        Seriousnizep();
        Person person = DeserializePerson();
        System.out.println(MessageFormat.format("name,age,sex", person.getName(), person.getAge(), person.getSex()));
    }


    public static void Seriousnize() throws IOException {

        Person person = new Person();
        person.setAge(19);
        person.setName("郑森文");
        person.setSex("女");

        ObjectOutputStream output = new ObjectOutputStream(new FileOutputStream(new File("D:/Person.txt")));
        output.writeObject(person);
        System.out.println("Person序列化成功！");
        output.close();
    }

    private static Person DeserializePerson()

    {

        try {
            ObjectInputStream input = new ObjectInputStream(new FileInputStream(new File("D:/Person.txt")));

            Person person = (Person) input.readObject();
            System.out.println("Person反序列化对象成功");

        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }


        return null;
    }

}
